package com.rdsm.adapter;

import java.util.List;

import com.rdsm.modle.DataModle;
import com.rdsm.modle.DataService;
import com.rdsm.read.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class DataItemAdapter extends BaseAdapter {

	private Context context;
	private List<DataModle>listData;
	//private ImageTextView imageTextView;
	private TextView img;
	private TextView title;
	private TextView author;
	private TextView time;
	public DataItemAdapter(Context mContext,DataService service) {
		this.context=mContext;
		listData=service.getItemData();
	}
	
	@Override
	public int getCount() {
		return listData.size();
	}

	@Override
	public Object getItem(int position) {
		return listData.get(position);
	}

	@Override
	public long getItemId(int position) {
		
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		DataModle data=listData.get(position);
		convertView=LayoutInflater.from(context).inflate(R.layout.imagetextview, null);
		img=(TextView) convertView.findViewById(R.id.img);
		img.setBackgroundResource(R.drawable.index_test_zzqk);
		title=(TextView) convertView.findViewById(R.id.title);
		title.setText(data.getTitle());
		author=(TextView) convertView.findViewById(R.id.author);
		title.setText(data.getAuthor());
		time=(TextView) convertView.findViewById(R.id.time);
		title.setText(data.getTime());
		return convertView;
	}

}
